package com.xxl.job.executor.entity.dto;

/**
 * @author hanson.huang
 * @version V1.0
 * @ClassName Result
 * @date 2024/12/20 16:45
 **/
public class Result<T> {
    public static String SUCCESS_STATUS = "1";
    public static String SUCCESS_MSG = "成功";

    private String status;
    private String message;
    private T resultbody;

    public Result(String status, String message, T resultbody){
        this.status = status;
        this.message = message;
        this.resultbody = resultbody;
    }

    /**
     * 成功返回
     * @param
     * @return com.job51.common.entity.dto.Result
     */
    public static Result success(){
        return new Result<>(SUCCESS_STATUS, SUCCESS_MSG, null);
    }
    public static<T> Result<T> success(T resultbody){
        return new Result<>(SUCCESS_STATUS, SUCCESS_MSG, resultbody);
    }


    /**
     * 根据status和message返回错误
     * @param status
     * @param message
     * @return com.job51.common.entity.dto.Result
     */
    public static Result fail(String status, String message){
        return fail(status, message, null);
    }
    public static<T> Result<T> fail(String status, String message, T resultbody){
        return new Result<>(status, message, resultbody);
    }

    public static String getSuccessStatus() {
        return SUCCESS_STATUS;
    }

    public static void setSuccessStatus(String successStatus) {
        SUCCESS_STATUS = successStatus;
    }

    public static String getSuccessMsg() {
        return SUCCESS_MSG;
    }

    public static void setSuccessMsg(String successMsg) {
        SUCCESS_MSG = successMsg;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getResultbody() {
        return resultbody;
    }

    public void setResultbody(T resultbody) {
        this.resultbody = resultbody;
    }
}